<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>标签管理</title>
<script type="text/javascript" src="Public/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="Public/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="Public/js/lazyload.js"></script>
<script type="text/javascript" src="Public/artDialog/artDialog.source.js?skin=default" charset="utf-8"></script>
<script type="text/javascript" src="Public/js/jquery.ae.image.resize.min.js"></script>
<script type="text/javascript" src="Public/js/province_city_county.js"></script>
<script type="text/javascript" src="Public/js/jquery.date.js"></script>

<link rel="stylesheet" href="Public/bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="theme/default/css/common.css">
<link rel="stylesheet" href="Public/css/homeindex.css">

  <!--[if lte IE 6]>
  <link rel="stylesheet" type="text/css" href="/Public/bootstrap/css/bootstrap-ie6.css">
  <![endif]-->
  <!--[if lte IE 7]>
  <link rel="stylesheet" type="text/css" href="/Public/bootstrap/css/ie.css">
  <![endif]-->
</head>

<body>
<include file="./template/default/Public/header-logined.html" />

    <div class="container main">
      <div class="row-fluid">
        <div class="span3">
          <include file="./template/default/Public/sidebar.html" />
        </div><!--/span-->
        <div class="content span9">
          
          <div class="well">
          	<div class="page-header"><h3>标签管理</h3></div>
<script type="text/javascript">
function saveLabel(){
	$('#out_notice').show();
	if($.trim($('#label_name').val()=='')){
	$('#out_notice').html('标签名称不能为空!');
	return false;	
	}
	var formData=$("#form-label").serialize();
	
	$.ajax({
		url:"/index.php?s=/Home/User/saveLabel/",
		type:"POST",
		data:formData,
		dataType:"json",
		success:function(json){
			
			if(json.flag=='fail'){
				$('#out_notice').html('标签添加不成功!');
			}else if(json.flag=='success'){
				$('#out_notice').html('标签添加成功!');
				
			}
			label_list();
			
		}
		});
	
	
		
}

</script>            
<form class="form-horizontal" onSubmit="return false;" id="form-label">

<div class="control-group">
	<label class="control-label">标签名称: </label>
    <div class="controls">
    	<input type="text" name="label_name" id="label_name">
    </div>
</div>
<div class="control-group">
<label class="control-label">期限 </label>
<div class="controls">
<label class="checkbox inline"><input type="radio" name="use_limit" value="nolimit" checked>不限</label>
<label class="checkbox inline"><input type="radio" name="use_limit" value="month">当月</label>
<span class="help-inline">注：当月--该标签会根据时间判断是否在当月的标签列表出现</span>
</div>
</div>

<div class="control-group">
	<label class="control-label">排序 </label>
    <div class="control">
    &nbsp;
    <input type="text" name="label_sort" id="label_sort" style="width:30px" value="0">
    
    </div>
</div>



<div class="form-actions">
  <button type="button" class="btn" onClick="saveLabel()">添加标签</button>
&nbsp;<span class="red" id="out_notice"></span>
</div>

</form>

<script type="text/javascript">
function getLocalFormatTime(nS) { 
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");  
}

function label_list(){
	
	$.ajax({
		url:"/index.php",
		type:"GET",
		data:"s=/Home/User/LabelLIst",
		dataType:"JSON",
		success:function(json){
			var html='';
			var lb_createdate = '';
			if(json!=null){
			$.each(json,function(dataIndex,data){
				lb_createdate = new Date(data['lb_createdate']*1000);
				html+='<tr><td>'+(dataIndex+1)+'</td><td>'+data.lb_name+'</td><td>'+lb_createdate.format("yyyy-MM-dd hh:mm:ss")+'</td><td><a href="/index.php?s=/Home/User/label_edit/id/'+data.lb_id+'">编辑</a>&nbsp;&nbsp;<a onclick="delable(\''+data['lb_id']+'\')" href="javascript:void(0)">删除</a>			</td></tr>';
			});
			$('#label_body').html(html);
			}
		}
			
	});	
}
</script>
<div>
<table class="table">
<thead>
	<tr>
    	<th>序</th>
    	<th>标签名称</th>
        <th>添加时间</th>
        
        <th>操作</th>
    </tr>
</thead>
<tbody id="label_body">

</tbody>
</table>
</div>
<script type="text/javascript">
label_list();
</script>            
            
          </div><!--end well-->
         
        </div><!--/span-->
      </div><!--/row-->
      
      </div>
    
<include file="./template/default/Public/footer-logined.html" />
    
</body>
</html>